# 合并两个有序数组

n1 = [1, 2, 3, 0, 0, 0]
n2 = [2, 5, 7]


def merge(num1, m, num2, n):
    p1, p2, p = m - 1, n - 1, m + n - 1
    while p1 >= 0 and p2 >= 0:
        if num1[p1] >= num2[p2]:
            num1[p] = num1[p1]
            p1 -= 1
        else:
            num1[p] = num2[p2]
            p2 -= 1
    p -= 1
    num1[:p2 + 1] = num2[:p2 + 1]


print(merge(n1, 3, n2, 3))
